package com.twu.biblioteca;

import java.util.Iterator;
import java.util.List;

/**
 * Created by thoughtworker on 1/17/14.
 */
public class Library{
    private List<LibraryBook> bookList;
    private IOManager ioManager;

    public Library(List<LibraryBook> bookList, IOManager ioManager) {
        this.bookList = bookList;
        this.ioManager = ioManager;
    }



    public LibraryBook findBook(String title) {
        for (LibraryBook libraryBook : bookList) {
            if(libraryBook.toString().equals(title)){
                return libraryBook;
            }
        }
        return null;
    }

    public void listBooks() {
        for (LibraryBook book : bookList) {
            if(book.isAvailable()){
                ioManager.print(book.toString());
                break;
            }
        }
    }
}
